<?php
foreach($reviews as $i=>$review)
{
?>
    <div class="cAll">
        <div class="cImage">
			<img  class="img-content png" src="/images/avatarno.jpg" width="60" border="0"/>
		</div>
        <div>
            <div class="cText"><?php echo $review['cComment']?></div>
            <div class="cboss"><?php echo $review['cName']?> - <?php echo $review['cEmail']?></div>
        </div>
    </div>
    <div class="clear dots"></div>
<?
}
?>
<div id="bookform">
    <div style="font-size: 17px;padding-bottom:20px"><?php echo __('Leave a review')?></div>
    <div style="padding-left: 25px;">
        <form method="post" onsubmit="postComment(this);return false;">
        <input type="hidden" name="ParentId" value="<?php echo $ParentIdCommen?>" />
        <input type="hidden" name="Type" value="<?php echo $TypeComment?>" />
        <table width="100%">
        <tr>
            <td><?php echo __('Your name')?>:</td>
            <td><input type="text" name="Name" class="tfield" /></td>
        </tr>
        <tr>
            <td><?php echo __('Your email')?>:</td>
            <td><input type="text" name="Email" class="tfield" /></td>
        </tr>
        <tr>
            <td><?php echo __('Message')?>:</td>
            <td>
                <textarea name="Comment" class="tfield" style="width: 90%;height:60px;"></textarea>
            </td>
        </tr>
        <tr>
            <td><?php echo __('Spam code')?>:</td>
            <td>
                <input type="text" name="SpamCode" id="SpamCode" maxlength="5" class="tfield" style="width: 50px;" />
        	   <img id="imgcodespam" src="/ImgSpam/<?echo time()?>.jpg" width="100" height="20" alt="Code Spam" 
        	   onclick="this.src='/ImgSpam/'+Math.random()+'.jpg'" class="cpointer" title="Click to refresh"/>
            </td>
        </tr>
        <tr>
            <td></td>
            <td><input type="submit" id="butsend" value="<?echo __('Send')?>" /></td>
        </tr>
        </table>
        </form>
    </div>
</div>

<script type="text/javascript">
var ajpost      = new ajaxLoader();
ajpost.init({url: '/as/insertreview',func:postsuccess});
function postComment(f)
{
    if(f.Name.value=='')
    {
        alert('<?php echo __('Please enter your name')?>!');
        f.Name.focus();
        return false;
    }
    else if(!isEmail(f.Email.value))
    {
        alert('<?php echo __('Please enter your email')?>!');
        f.Email.focus();
        return false;
    }
    else if(f.Comment.value=='')
    {
        alert('<?php echo __('Please enter your message')?>!');
        f.Comment.focus();
        return false;
    }
    else if(f.SpamCode.value=='')
    {
        alert('<?php echo __('Please enter security code')?>!');
        f.SpamCode.focus();
        return false;
    }
    post='';
	for(i=0;i<200;i++)
	{
		if(f[i])
			post+=f[i].name+"="+ajpost.escapeHTML(f[i].value)+"&";
		else break;
	}
    ajpost.send(post);
    getId('butsend').value="<?php echo __('Sending')?>...";
}

function postsuccess(obj)
{
    getId('butsend').value="<?php echo __('Send')?>";
    if(obj.status=='spam')
    {
        getId('SpamCode').value='';
        getId('imgcodespam').src = '/ImgSpam/'+Math.random()+'.jpg';        
    }
    else if(obj.status=='ok')
    {
        getId('bookform').innerHTML=obj.msg;
        return;
    }
    alert(obj.msg);
}
</script>